<?php
declare (strict_types=1);

namespace app\api\controller;


use app\api\logic\LogicalProcess;
use app\api\model\Member;
use think\facade\Db;

class Profile extends Api
{
    /**
     * {@inheritdoc}
     * rules:
     * actions 控制器列表: * 全部控制器
     * roles 允许访问角色:
     * all 全部;
     * no_all 不允许任何人进;
     * login 登录(默认);
     * allow 验证规则:
     * no_checkTime 不验证时间戳;
     * no_checkSign  不验证签名;
     */
    protected $auth = [
        [
            'actions' => ['ceshi'],
            'roles' => 'all',
            'allow' => [],
        ]
    ];
    protected $model;
    protected $redis;

    public function initialize()
    {
        parent::initialize();
        $this->model = new Member();
    }

    //获取用户信息
    public function getUserInfo()
    {
        $res = $this->model->userInfo($this->userId);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //修改用户昵称
    public function updateUserNickName()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->updateUserNickName($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //实名认证
    public function authMember()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->authMember($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //修改qq WeChat
    public function updateSocial()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->socializeInfo($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //修改密码
    public function updatePwd()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->updatePwd($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //忘记密码
    public function forgetPwd()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->forgetPwd($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //店长拥有的npc
    public function getNpfByShopManager()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getNpfByShopManager($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


    //店长转增用户npc
    public function giftNfcToUser()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->giftNfcToUser($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //已转增的npc
    public function getNfcByIsUse()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getNfcByIsUse($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


    // 用户取货单
    public function getTakeData()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getTakeData($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


    // 店长取货单
    public function getTakeDataByShopManager()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getTakeDataByShopManager($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    // 用户取货
    public function takeNfc()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->takeNfc($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //用户激活悟空挖矿
    public function activateWuKong()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->activateWuKong($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


    //转增经书
    public function giftBookSToUser()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->giftBookSToUser($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


    //邀请统计
    public function getInviteStat()
    {
        $res = $this->model->getInviteStat($this->userId);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //转增记录
    public function getGiftRecord()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getGiftRecord($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }

    //获取经书变动记录 排除转增
    public function getBooksChangeRecord()
    {
        $params = request()->param();
        $params['user_id'] = $this->userId;
        $res = $this->model->getBooksChangeRecord($params);
        $this->result($res['msg'], $res['data'], $res['code']);
    }


}